package configuration.dataObjects
{
	import mx.collections.ArrayCollection;
	import common.utils.DateManager;
	
	[Bindable]
	public class VendorDO
	{
		public var INTERNAL_VENDOR_NUM:String = "0";
		public var VENDOR_ID:String = "";
		public var NAME:String = "";
		public var ADDRESS1:String = "";
		public var ADDRESS2:String = "";
		public var CITY:String = "";
		public var STATE:String = "";
		public var COUNTRY:String = "";
		public var POSTAL_CODE:String = "";
		public var PARENT:String = "";
		public var ATTENTION_TO:String = "";
		public var PHONE_NUM:String = "";
		public var FAX_NUM:String = "";
		public var EMAIL:String = "";
		public var ACTIVE:String = "Y";
		public var CARRIER:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		
		public function CustomerDO():void
		{
			
		}
		
		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}			
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
			<VENDOR>
				<INTERNAL_VENDOR_NUM>{INTERNAL_VENDOR_NUM}</INTERNAL_VENDOR_NUM>
				<VENDOR_ID>{VENDOR_ID}</VENDOR_ID>
				<NAME>{NAME}</NAME>
				<ADDRESS1>{ADDRESS1}</ADDRESS1>
				<ADDRESS2>{ADDRESS2}</ADDRESS2>
				<CITY>{CITY}</CITY>
				<STATE>{STATE}</STATE>
				<COUNTRY>{COUNTRY}</COUNTRY>
				<POSTAL_CODE>{POSTAL_CODE}</POSTAL_CODE>
				<PARENT>{PARENT}</PARENT>
				<ATTENTION_TO>{ATTENTION_TO}</ATTENTION_TO>
				<PHONE_NUM>{PHONE_NUM}</PHONE_NUM>
				<FAX_NUM>{FAX_NUM}</FAX_NUM>
				<EMAIL>{EMAIL}</EMAIL>
				<ACTIVE>{ACTIVE}</ACTIVE>
				<CARRIER>{CARRIER}</CARRIER>
				<USER_STAMP>{USER_STAMP}</USER_STAMP>
				<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>			
			</VENDOR>;
			return xmlObj;
		}

		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var wavDO:VendorDO = new VendorDO();
				wavDO.Init(xml);
				ac.addItem(wavDO);
			}
			return ac;
		}
	}
}